<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:conv="clr-namespace:QuickZip.Converters"            
    xmlns:sys="clr-namespace:System;assembly=mscorlib" 
    xmlns:lc="clr-namespace:LoadingControl.Control"
    xmlns:ce="clr-namespace:FileExplorer.WPF.Animations"
    xmlns:bc="clr-namespace:FileExplorer.WPF.BaseControls"
    xmlns:uc="clr-namespace:FileExplorer.WPF.UserControls"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Default/Brushes.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Default/Geometry.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Common/Converters.xaml" />
        <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Common/Buttons.xaml" />
    </ResourceDictionary.MergedDictionaries>


    <Style x:Key="focusVisualStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Stroke="#8E6EA6F5" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="BreadcrumbItemTemplate" TargetType="{x:Type bc:BreadcrumbItem}">
        <Grid Name="MainGrid" SnapsToDevicePixels="True" 
              Margin="0,0"  HorizontalAlignment="Stretch">
            <!-- If Is separator, display separator -->
            <Separator Visibility="{Binding IsSeparator, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource btv}}" />
            <!-- Otherwise display a grid with popup -->
            <Grid Visibility="{Binding IsSeparator, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource fbtvc}}"  >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="0"  />
                </Grid.ColumnDefinitions>
                <!-- Header -->
                <DockPanel x:Name="basePanel" SnapsToDevicePixels="True" Grid.Column="0" Margin="0"  
                           LastChildFill="True">
                    
                   
                    <!-- Header Toggle Button - visible requires ShowToggle and HasItems -->
                    <bc:HotTrack IsSelected="{TemplateBinding IsMouseOver}"
                                 x:Name="headerToggleHL" DockPanel.Dock="Right" 
                                 BorderThickness="{TemplateBinding BorderThickness}"
                                 SelectedBorderBrush="{TemplateBinding BorderBrush}"
                                 Visibility="{Binding ShowToggle, RelativeSource={RelativeSource TemplatedParent}, 
                                        Converter={StaticResource btvc}}"
                                >
                        <!-- DropDown Popup -->
                        <bc:DropDown Visibility="{Binding HasItems, RelativeSource={RelativeSource TemplatedParent}, 
                                        Converter={StaticResource btvc}}"     
                                    IsDropDownOpen="{Binding IsDropDownOpen, Mode=TwoWay, 
                                            RelativeSource={RelativeSource TemplatedParent}}">
                            <ScrollViewer CanContentScroll="True"  HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"
                                                      Visibility="{Binding Path=IsLoading, Converter={StaticResource fbtvc},
                                                        Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                                      >
                                <ItemsPresenter x:Name="itemList" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                                                     SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"                                                      
                                                     MaxHeight="{Binding DropDownHeight, RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" 
                                                     Width="{Binding DropDownWidth, RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" 
                                                     KeyboardNavigation.DirectionalNavigation="None"
                                                     VirtualizingStackPanel.IsVirtualizing="True" 
                                                     VirtualizingStackPanel.VirtualizationMode="Standard"                                                     
                                                    >
                                </ItemsPresenter>
                            </ScrollViewer>


                        </bc:DropDown>
                    </bc:HotTrack>
                    <!-- Header Content - visible requres ShowCaption  -->
                    <bc:HotTrack x:Name="headerHL"  BorderThickness="{TemplateBinding BorderThickness}"
                                 SelectedBorderBrush="{TemplateBinding BorderBrush}"                                 
                                 Visibility="{Binding ShowCaption, RelativeSource={RelativeSource TemplatedParent},
                                            Converter={StaticResource btvc}}"
                                 IsDragging="{Binding IsMouseOver, ElementName=headerToggleHL}">
                        <Button x:Name="buttonCurrent"  HorizontalAlignment="Stretch"                                                  
                                                Template="{StaticResource BaseButton}" 
                                                Grid.RowSpan="2" >
                            <Button.Content>
                                <DockPanel>
                                    <!-- Add some space in front if it's inside menu  -->
                                    <Rectangle Width="5" DockPanel.Dock="Left" 
                                            Visibility="{Binding IsTopLevel,
                                                RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource fbtvc}}" />
                                    <bc:MultiContentControl 
                                                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                        ContentTemplate2="{TemplateBinding IconTemplate}"
                                                        ContentVisible2="{TemplateBinding ShowIcon}"
                                    />
                                </DockPanel>
                            </Button.Content>
                        </Button>
                    </bc:HotTrack>
                </DockPanel>


            </Grid>

        </Grid>

        <ControlTemplate.Triggers>

            <!--<EventTrigger RoutedEvent="bc:BreadcrumbItem.ShowingCaption"  >
                <BeginStoryboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerToggleHL" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="0:0:0.2" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerHL" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="0:0:0.2" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Storyboard.TargetName="headerHL" FillBehavior="Stop" 
                                                     Storyboard.TargetProperty="MaxWidth" From="0" To="200" Duration="00:00:0.5" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>

            <EventTrigger RoutedEvent="bc:BreadcrumbItem.HidingCaption">
                <BeginStoryboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerToggleHL" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="0:0:0.2" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerHL" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="0:0:0.2" />
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Storyboard.TargetName="headerHL" FillBehavior="Stop" 
                                                     Storyboard.TargetProperty="MaxWidth" From="200" To="0" Duration="00:00:0.5" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>-->


        </ControlTemplate.Triggers>
    </ControlTemplate>


    <Style x:Key="{x:Type bc:BreadcrumbItem}"                       
           TargetType="{x:Type bc:BreadcrumbItem}" >

        <!--<Setter Property="Height" Value="20"  />-->
        <Setter Property="HorizontalAlignment" Value="Stretch"  />
        <Setter Property="VerticalAlignment" Value="Stretch"  />
        <Setter Property="FocusVisualStyle" Value="{StaticResource focusVisualStyle}" />
        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="IsDropDownOpen" Value="{Binding IsExpanded, Mode=TwoWay}"  />
        <Setter Property="ItemContainerStyle" 
                Value="{Binding ItemContainerStyle, 
            RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />
        <Setter Property="Template" Value="{StaticResource BreadcrumbItemTemplate}" />
        <Setter Property="MaxHeight" Value="{Binding ActualHeight, Mode=OneWay,
            RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel IsItemsHost="True" Orientation="Vertical" 
                                VirtualizingPanel.IsVirtualizing="True"
                                VirtualizingPanel.IsContainerVirtualizable="True"
                                VirtualizingPanel.VirtualizationMode="Standard"
                                />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <!--<Setter Property="HeaderTemplate" Value="{Binding HeaderTemplate, Mode=OneWay,
            RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />
        <Setter Property="IconTemplate" Value="{Binding IconTemplate, Mode=OneWay,
            RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />-->
    </Style>

    <Style x:Key="{x:Type bc:BreadcrumbOverflowPanel}"                       
           TargetType="{x:Type bc:BreadcrumbOverflowPanel}" BasedOn="{StaticResource {x:Type ItemsControl}}" >

        <Setter Property="Background" Value="Transparent" />

        <Setter Property="HeaderTemplate" Value="{Binding HeaderTemplate, 
                                                    RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />
        <Setter Property="IconTemplate" Value="{Binding IconTemplate, 
                                                    RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />

        <Setter Property="ItemContainerStyle" Value="{DynamicResource {x:Type bc:BreadcrumbItem}}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel IsItemsHost="True" Orientation="Vertical" 
                                VirtualizingPanel.IsVirtualizing="True"
                                VirtualizingPanel.IsContainerVirtualizable="True"
                                VirtualizingPanel.VirtualizationMode="Standard"
                                />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsSource" Value="{Binding OverflowedItems, 
                                                    RelativeSource={RelativeSource AncestorType={x:Type bc:BreadcrumbCore}}}" />
    </Style>

    <!--<conv:BoolToVisibilityConverter x:Key="btv" />-->

    <Style x:Key="{x:Type bc:BreadcrumbCore}"                       
           TargetType="{x:Type bc:BreadcrumbCore}" >
        <!--<Setter Property="Height" Value="30" />-->
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ItemContainerStyle" Value="{DynamicResource {x:Type bc:BreadcrumbItem}}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <bc:BreadcrumbCorePanel IsItemsHost="True"   />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="Template">
            <Setter.Value>

                <ControlTemplate TargetType="{x:Type bc:BreadcrumbCore}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" IsHitTestVisible="True"  
                            BorderThickness="{TemplateBinding BorderThickness}" MinHeight="25">
                        <DockPanel Margin="1,0" Background="Transparent" IsHitTestVisible="True" >
                            <bc:DropDown DockPanel.Dock="Left" 
                                         Visibility="{Binding ShowDropDown, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource btvc}}"
                                         IsDropDownOpen="{Binding IsDropDownOpen, Mode=TwoWay, 
                                            RelativeSource={RelativeSource TemplatedParent}}" 
                                         VerticalAlignment="Stretch" >
                                <bc:DropDown.Header>
                                    <Grid>
                                        <Path Stroke="Black" StrokeThickness="1.2" Data="{StaticResource ExpanderArrow}"
                                            HorizontalAlignment="Center" VerticalAlignment="Center" 
                                            Visibility="{Binding IsOverflowed, RelativeSource={RelativeSource TemplatedParent},
                                            Converter={StaticResource btv}}"
                                          Margin="{TemplateBinding Padding}" IsHitTestVisible="True" />

                                        <ToggleButton Template="{StaticResource BasicArrowButton}" IsHitTestVisible="False" 
                                                      Visibility="{Binding IsOverflowed, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource fbtv}}"
                                                      IsChecked="{Binding IsDropDownOpen, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                      />
                                    </Grid>
                                </bc:DropDown.Header>
                                <bc:DropDown.Content>

                                    <ScrollViewer MaxHeight="{TemplateBinding DropDownHeight}" 
                                                  Width="{TemplateBinding DropDownWidth}"
                                                  HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
                                        <StackPanel Orientation="Vertical" >
                                            <bc:BreadcrumbOverflowPanel ItemsSource="{TemplateBinding OverflowedItems}" />
                                            <Separator HorizontalAlignment="Stretch" Visibility="{Binding IsOverflowed, 
                                                            RelativeSource={RelativeSource TemplatedParent},
                                                            Converter={StaticResource btv}}" />
                                            <bc:BreadcrumbOverflowPanel ItemsSource="{TemplateBinding RootItemsSource}" />
                                        </StackPanel>

                                    </ScrollViewer>
                                </bc:DropDown.Content>

                            </bc:DropDown>
                            <ItemsPresenter x:Name="PART_BreadcrumbList" HorizontalAlignment="Left" VerticalAlignment="Center" 
                                                     SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"                                        
                                                     KeyboardNavigation.DirectionalNavigation="None"
                                            
                                            >
                            </ItemsPresenter>

                        </DockPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>


</ResourceDictionary>
